package com.openbravo.pos.printer.escpos;

import javax.swing.JComponent;

import net.xeoh.plugins.base.annotations.PluginImplementation;


import com.openbravo.pos.config.ParametersConfig;
import com.openbravo.pos.printer.DevicePrinter;
import com.openbravo.pos.printer.PrinterWritterPool;
import com.openbravo.pos.printer.TicketPrinterException;
import com.openbravo.pos.printer.config.ParametersComm;

@PluginImplementation
public class DevicePrinterStar extends AbstractDevicePrinterESCPOS {

	@Override
	public String getPrinterType() {
		return "star";
	}
	
	

	public DevicePrinterStar() {
		
	}


	public DevicePrinterStar(String sPrinterParam1, String sPrinterParam2)
			throws TicketPrinterException {
		//m_sName = AppLocal.getIntString("Printer.Serial");
        m_CommOutputPrinter = PrinterWritterPool.INSTANCE.getPrinterWritter(sPrinterParam1, sPrinterParam2);
        m_codes =  new CodesStar();
        m_trans = new UnicodeTranslatorStar();

        // Inicializamos la impresora
        m_CommOutputPrinter.init(ESCPOS.INIT);

        m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); // A la impresora
        m_CommOutputPrinter.init(m_codes.getInitSequence());
        m_CommOutputPrinter.write(m_trans.getCodeTable());

        m_CommOutputPrinter.flush();  

	}

	@Override
	public JComponent getPrinterComponent() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public DevicePrinter init(String sPrinterParam1, String sPrinterParam2)
			throws TicketPrinterException {
		// TODO Auto-generated method stub
		return new DevicePrinterStar(sPrinterParam1, sPrinterParam2);
	}

	@Override
	public ParametersConfig getConfiguration() {
	     return new ParametersComm();
	}

}
